const { createHmac } = require('crypto');

const userName = "小明";
const secret = 'abcdefg'; // 加盐
const hash = createHmac('sha256', secret)
               .update(userName)
               .digest('hex');
console.log(hash);